package com.happyclub.lbjcontroller;

import com.happyclub.lbj.service.IActivityUserService;
import com.happyclub.pojo.TbActivityUser;
import com.happyclub.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 高欢
 * @description TODO
 * @date 2019/4/5
 */
@RestController
@RequestMapping("/activityUser")
public class ActivityUserController {

    @Autowired
    IActivityUserService iActivityUserService;

    //报活动
    @RequestMapping(value = "/saevActivityUser/{activityId}/{userId}",method = RequestMethod.POST)
    public JsonResult saevActivityUser(@PathVariable String activityId ,@PathVariable String userId){
        TbActivityUser activityUser = new TbActivityUser();
        activityUser.setActivityId(activityId);
        activityUser.setUserId(userId);
        return iActivityUserService.insertActivityUser(activityUser);
    }

    //取消报名
    @RequestMapping(value = "/cancelActivityByUser/{activityId}/{userId}",method = RequestMethod.DELETE)
    public JsonResult cancelActivityByUser(@PathVariable String activityId ,@PathVariable String userId){
        return iActivityUserService.cancelActivityByUser(activityId,userId);
    }
}
